import os, fnmatch
from lxml import etree

def findFile(name, directory=os.curdir):
	try:
		fle = fnmatch.filter(os.listdir(directory),name)
		if len(fle)== 0 :
			return None	
	except:
		print 'No existe el directorio'
		return None
		
	try:
		parse = etree.XMLParser(dtd_validation=True,attribute_defaults=True)
		xml_etree = etree.parse(''.join([directory,fle[0]]),parse)
	except etree.XMLSyntaxError,e:
		print("El xml no es valido: %s", e)
	except etree.DTDParseError, d:
		print("El xml no es valido: %s", d)
	# Raiz del arbol

	return  xml_etree.getroot()
